/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entityprojet;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author T.Ron
 */
@Entity
@Table(name = "POSTEBUDGETAIRE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Postebudgetaire.findAll", query = "SELECT p FROM Postebudgetaire p"),
    @NamedQuery(name = "Postebudgetaire.findByIdPb", query = "SELECT p FROM Postebudgetaire p WHERE p.idPb = :idPb"),
    @NamedQuery(name = "Postebudgetaire.findByComptepb", query = "SELECT p FROM Postebudgetaire p WHERE p.comptepb = :comptepb"),
    @NamedQuery(name = "Postebudgetaire.findByIntitulepb", query = "SELECT p FROM Postebudgetaire p WHERE p.intitulepb = :intitulepb"),
    @NamedQuery(name = "Postebudgetaire.findBySens", query = "SELECT p FROM Postebudgetaire p WHERE p.sens = :sens")})
public class Postebudgetaire implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_PB")
    private Integer idPb;
    @Basic(optional = false)
    @Column(name = "COMPTEPB")
    private String comptepb;
    @Basic(optional = false)
    @Column(name = "INTITULEPB")
    private String intitulepb;
    @Column(name = "SENS")
    private Short sens;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "postebudgetaire")
    private Collection<Budgetpb> budgetpbCollection;
    @JoinColumn(name = "SA", referencedColumnName = "SA")
    @ManyToOne(optional = false)
    private Sectionanal sa;

    public Postebudgetaire() {
    }

    public Postebudgetaire(Integer idPb) {
        this.idPb = idPb;
    }

    public Postebudgetaire(Integer idPb, String comptepb, String intitulepb) {
        this.idPb = idPb;
        this.comptepb = comptepb;
        this.intitulepb = intitulepb;
    }

    public Integer getIdPb() {
        return idPb;
    }

    public void setIdPb(Integer idPb) {
        this.idPb = idPb;
    }

    public String getComptepb() {
        return comptepb;
    }

    public void setComptepb(String comptepb) {
        this.comptepb = comptepb;
    }

    public String getIntitulepb() {
        return intitulepb;
    }

    public void setIntitulepb(String intitulepb) {
        this.intitulepb = intitulepb;
    }

    public Short getSens() {
        return sens;
    }

    public void setSens(Short sens) {
        this.sens = sens;
    }

    @XmlTransient
    public Collection<Budgetpb> getBudgetpbCollection() {
        return budgetpbCollection;
    }

    public void setBudgetpbCollection(Collection<Budgetpb> budgetpbCollection) {
        this.budgetpbCollection = budgetpbCollection;
    }

    public Sectionanal getSa() {
        return sa;
    }

    public void setSa(Sectionanal sa) {
        this.sa = sa;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPb != null ? idPb.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Postebudgetaire)) {
            return false;
        }
        Postebudgetaire other = (Postebudgetaire) object;
        if ((this.idPb == null && other.idPb != null) || (this.idPb != null && !this.idPb.equals(other.idPb))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entityprojet.Postebudgetaire[ idPb=" + idPb + " ]";
    }
    
}
